package com.smart.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smart.pojo.OutboundBill;
import com.smart.pojo.ResultBean;
import com.smart.req.PageData;
import com.smart.resp.OutboundBillResp;
import com.smart.service.IOutboundBillService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author lyj
 * @since 2023-05-17
 */
@RestController
@RequestMapping("/outbound-bill")
public class OutboundBillController {

    @Autowired
    private IOutboundBillService outboundBillService;

    @GetMapping("queryPage")
    public ResultBean queryPage(PageData pageData) {
        Page<OutboundBillResp> page = new Page<>(pageData.getPageNum(), pageData.getPageSize());
        outboundBillService.queryPage(page);
        return ResultBean.success(page);
    }

    @DeleteMapping("deleteById/{id}")
    @RequiresPermissions({"outbound:del"})
    public ResultBean deleteById(@PathVariable("id") Long id) {
        System.out.println("删除的出库记录的id：" + id);
        boolean rs = outboundBillService.removeById(id);
        return rs ? ResultBean.success() : ResultBean.error();
    }
}
